import requests
import app



class IHRMStaff:
    def __init__(self):
        self.staff_url=app.BASE_URL+"/api/sys/user?page=1&size=10"
        self.insert_url=app.BASE_URL+"/api/sys/user"
        self.update_url=app.BASE_URL+"/api/sys/user/{}"
        self.select_url=app.BASE_URL+"/api/sys/user/{}"
        self.delete_url=app.BASE_URL+"/api/sys/user/{}"
    #员工管理
    def staff(self,token):
        return requests.get(self.staff_url,headers={"Authorization": token})
    #员工添加
    def insert_staff(self,login_data,token):
        return requests.post(self.insert_url,json=login_data,headers={"Authorization": token})
    #员工修改
    def update_staff(self,update_data,token,staff_id):
        return requests.put(url=self.update_url.format(staff_id),json=update_data,headers={"Authorization":token})
    #员工查询
    def select_staff(self,token,staff_id):
        return requests.get(url=self.select_url.format(staff_id),headers={"Authorization": token})
    #员工删除
    def delete_staff(self,token,staff_id):
        return requests.delete(url=self.delete_url.format(staff_id),headers={"Authorization": token})